﻿// -----------------------------------------------------------------------
// <copyright file="Win32.cs" company="Abyssalsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Gui.BaseForm
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.InteropServices;
    using System.Text;

    /// <summary>
    /// Win32 is just a placeholder for some Win32 imported definitions
    /// </summary>
    public class Win32
    {
        /// <summary>
        /// Import Get asynchronous key
        /// </summary>
        /// <param name="vKey">The key</param>
        /// <returns>The state of the key</returns>
        [DllImport("user32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern short GetAsyncKeyState(int vKey);

        /// <summary>
        /// Get desktop window
        /// </summary>
        /// <returns>A pointer that represents the desktop</returns>
        [DllImport("user32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr GetDesktopWindow();

        /// <summary>
        /// VK is just a placeholder for VK (VirtualKey) general definitions
        /// </summary>
        public class VK
        {
            /// <summary>Constants used for Window messages</summary>
            public const int VKSHIFT = 0x10;

            /// <summary>Constants used for Window messages</summary>
            public const int VKCONTROL = 0x11;

            /// <summary>Constants used for Window messages</summary>
            public const int VKMENU = 0x12;

            /// <summary>Constants used for Window messages</summary>
            public const int VKESCAPE = 0x1B;

            /// <summary>
            /// Check if the key is pressed
            /// </summary>
            /// <param name="keyCode">The code of the key</param>
            /// <returns>Returns true if the key is pressed</returns>
            public static bool IsKeyPressed(int keyCode)
            {
                return (GetAsyncKeyState(keyCode) & 0x0800) == 0;
            }
        }

        /// <summary>
        /// WM is just a placeholder class for WM (WindowMessage) definitions
        /// </summary>
        public class WM
        {
            /// <summary>Constants used for Window messages</summary>
            public const int WMMOUSEMOVE = 0x0200;

            /// <summary>Constants used for Window messages</summary>
            public const int WMNCMOUSEMOVE = 0x00A0;

            /// <summary>Constants used for Window messages</summary>
            public const int WMNCLBUTTONDOWN = 0x00A1;

            /// <summary>Constants used for Window messages</summary>
            public const int WMNCLBUTTONUP = 0x00A2;

            /// <summary>Constants used for Window messages</summary>
            public const int WMNCLBUTTONDBLCLK = 0x00A3;

            /// <summary>Constants used for Window messages</summary>
            public const int WMLBUTTONDOWN = 0x0201;

            /// <summary>Constants used for Window messages</summary>
            public const int WMLBUTTONUP = 0x0202;

            /// <summary>Constants used for Window messages</summary>
            public const int WMKEYDOWN = 0x0100;
        }

        /// <summary>
        /// HT is just a placeholder for HT (HitTest) definitions
        /// </summary>
        public class HT
        {
            /// <summary>Constants used for Window messages</summary>
            public const int HTERROR = -2;

            /// <summary>Constants used for Window messages</summary>
            public const int HTTRANSPARENT = -1;

            /// <summary>Constants used for Window messages</summary>
            public const int HTNOWHERE = 0;

            /// <summary>Constants used for Window messages</summary>
            public const int HTCLIENT = 1;

            /// <summary>Constants used for Window messages</summary>
            public const int HTCAPTION = 2;

            /// <summary>Constants used for Window messages</summary>
            public const int HTSYSMENU = 3;

            /// <summary>Constants used for Window messages</summary>
            public const int HTGROWBOX = 4;

            /// <summary>Constants used for Window messages</summary>
            public const int HTSIZE = HTGROWBOX;

            /// <summary>Constants used for Window messages</summary>
            public const int HTMENU = 5;

            /// <summary>Constants used for Window messages</summary>
            public const int HTHSCROLL = 6;

            /// <summary>Constants used for Window messages</summary>
            public const int HTVSCROLL = 7;

            /// <summary>Constants used for Window messages</summary>
            public const int HTMINBUTTON = 8;

            /// <summary>Constants used for Window messages</summary>
            public const int HTMAXBUTTON = 9;

            /// <summary>Constants used for Window messages</summary>
            public const int HTLEFT = 10;

            /// <summary>Constants used for Window messages</summary>
            public const int HTRIGHT = 11;

            /// <summary>Constants used for Window messages</summary>
            public const int HTTOP = 12;

            /// <summary>Constants used for Window messages</summary>
            public const int HTTOPLEFT = 13;

            /// <summary>Constants used for Window messages</summary>
            public const int HTTOPRIGHT = 14;

            /// <summary>Constants used for Window messages</summary>
            public const int HTBOTTOM = 15;

            /// <summary>Constants used for Window messages</summary>
            public const int HTBOTTOMLEFT = 16;

            /// <summary>Constants used for Window messages</summary>
            public const int HTBOTTOMRIGHT = 17;

            /// <summary>Constants used for Window messages</summary>
            public const int HTBORDER = 18;

            /// <summary>Constants used for Window messages</summary>
            public const int HTREDUCE = HTMINBUTTON;

            /// <summary>Constants used for Window messages</summary>
            public const int HTZOOM = HTMAXBUTTON;

            /// <summary>Constants used for Window messages</summary>
            public const int HTSIZEFIRST = HTLEFT;

            /// <summary>Constants used for Window messages</summary>
            public const int HTSIZELAST = HTBOTTOMRIGHT;

            /// <summary>Constants used for Window messages</summary>
            public const int HTOBJECT = 19;

            /// <summary>Constants used for Window messages</summary>
            public const int HTCLOSE = 20;

            /// <summary>Constants used for Window messages</summary>
            public const int HTHELP = 21;
        }

        /// <summary>
        /// Some place holder
        /// </summary>
        public class Bit
        {
            /// <summary>
            /// Get high value
            /// </summary>
            /// <param name="iValue">The value</param>
            /// <returns>High word</returns>
            public static int HiWord(int iValue)
            {
                return (iValue >> 16) & 0xFFFF;
            }

            /// <summary>
            /// Get low value
            /// </summary>
            /// <param name="iValue">The value</param>
            /// <returns>Low word</returns>
            public static int LoWord(int iValue)
            {
                return iValue & 0xFFFF;
            }
        }
    }
}
